<template>
  <a-modal :visible="preview">
    <div>
      <!--<a-card  :bordered="false">-->
      <a-button @click="getSurvey">显示问卷</a-button>
      <!-- 在这个card里面的  -->
      <!--  @submit="handleSubmit"-->
      <a-form
        :model="survey.value"
        :rule="rules"
        style="display: flex; align-items: center; justify-content: center"
      >
        <a-form-item field="name" label="问卷名称" style="width: 100%">
          <a-input v-model="survey.name"></a-input>
        </a-form-item>
        <a-form-item field="description" label="问卷描述" style="width: 100%">
          <a-input v-model="survey.description"></a-input>
        </a-form-item>
        <a-form-item field="description" label="回答上线" style="width: 100%">
          <a-input v-model="survey.answerLimit"></a-input>
        </a-form-item>

        <!--  下面是问题-->

        <div
          v-for="(item, index) in survey.questions"
          :key="index"
          :label="`问题${index + 1}`"
        >
          <!--展示问题-->
          问题{{ index + 1 }} {{ item.stem }}
          <!--单选题-->
          <template v-if="item.questionType == '5'">
            <!--<a-form-item v-for="(opt, idx) in item.choices"-->
            <!--             :key="idx"-->

            <!--style="width: 450px">-->
            <!--<a-radio v-model="value1"></a-radio>-->
            <!--<a-input readonly="true">-->
            <!--  {{opt.content}}-->
            <!--</a-input>-->
            <a-table
              v-model:selectedKeys="selectedKeys"
              row-key="content"
              :columns="columns"
              :data="item.choices"
              :row-selection="danxuan"
              :pagination="pagination"
            />
            <!--</a-form-item>-->
          </template>
        </div>
      </a-form>
      <!--</a-card>-->
    </div>
  </a-modal>
</template>

<script setup>
  import { ref } from 'vue-demi';
  import { register } from '@/api/user';

  const danxuan = {
    type: 'radio',
  };

  const columns = [
    {
      title: '选项',
      dataIndex: 'content',
    },
  ];

  const pro1 = defineProps({
    dialogTableValue: {
      type: Object,
      default: () => {},
    },
  });
  const survey = ref({
    name: '',
    description: '',
    answerLimit: '',
    questions: [
      {
        id: '',
        questionType: '',
        stem: '',
        // 下一个题的Id
        nextId: '',
        choices: [
          {
            id: '',
            content: '',
            // 这个选项的下一个题
            goTo: '',
          },
        ],
      },
    ],
  });
  // 这个是父组件传过来的
  // props.dialogTableValue.data
  const all = ref(false);

  const getSurvey = () => {
    survey.value = pro1.dialogTableValue.data;
    console.log('这里是问卷ID');
    console.log(survey.value);
  };
</script>
